package Sj02;

import Sj02.entity.Operation;
import Sj02.factory.*;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        IFactory iFactory =null;
        //客户端代码
        Scanner input = new Scanner(System.in);
        System.out.println("请输入第一个操作数：");
        double x = input.nextDouble();
        System.out.println("请输入操作符：");
        String fu = input.next();
        System.out.println("请输入第二个操作数：");
        double y = input.nextDouble();
        switch (fu){
            case "+":
                iFactory = new AddFactory();
                break;
            case "-":
                iFactory = new SubFactory();
                break;
            case "*":
                iFactory = new MulFactory();
                break;
            case "/":
                iFactory = new DivFactory();
                break;
            case "%":
                iFactory = new MoFactory();
                break;
        }
        Operation opr = iFactory.createOperation();
        opr.setX(x);
        opr.setY(y);
        System.out.println(x+fu+y+"="+opr.getResult());
    }
}
